<?php
/**
 * Bootstrap of the application
 *
 * @author      Hyper <hyper@flashbay.com>
 * @copyright   Copyright (c) 2011 Sales Hero (http://www.saleshero.com)
 */

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

    protected function _initConfig()
    {
        $config = new Zend_Config($this->getOptions());
        Zend_Registry::set('config', $config);
    }

    protected function _initAutoload()
    {

    }

    protected function _initView()
    {
        $options = $this->getOptions();
        if (isset($options['resources']['view'])) {
            $view = new Zend_View($options['resources']['view']);
        } else {
            $view = new Zend_View;
        }
        if (isset($options['resources']['view']['doctype'])) {
            $view->doctype($options['resources']['view']['doctype']);
        }
        if (isset($options['resources']['view']['contentType'])) {
            $view->headMeta()->appendHttpEquiv('Content-Type',
                $options['resources']['view']['contentType']);
        }
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
            'ViewRenderer'
        );
        $viewRenderer->setView($view);
    }

    protected function _initDb()
    {
        $config = $this->getOption('database');
        $db = Zend_Db::factory($config['adapter'], $config['params']);
        Zend_Registry::set('db', $db);
    }

    protected function _initOther()
    {
        date_default_timezone_set('Europe/London');
    }
}

